/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *																 *
 *	TrabP3 - Trabalho P3										 *
 *																 *
 *	File:		P3App.cpp										 *
 *	Authors:	Rafael Kikuchi ( shinjikik@gmail.com )			 *
 *				Rafael Romeiro ( rafaelromeiro@gmail.com )		 *
 *	Date:		20/11/2008										 *
 *	License:	CC-GNU LGPL										 *
 *				http://creativecommons.org/licenses/LGPL/2.1/	 *
 *	Version:	0.1.0											 *
 *																 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <iostream>
#include <vector>

#include "P3App.h"

void P3App::init (vector<string> files)
{
	fileNames = files;
}

void P3App::go (void)
{
	while (fileNames.size())
	{
		cout << "Loading Graph (" << fileNames.back() << ")...";
		myGraph = new EuclideanGraph(fileNames.back().c_str());
		cout << " Done!" << endl;

		cout << "Writing TSP...";
		myGraph->TSP();
		myGraph->WriteTSP(( "[" + fileNames.back() + "]TSP.txt" ).c_str());
		cout << " Done!" << endl;

		cout << fileNames.back() << ":\n" << endl;
		cout << "  Total cost: " << myGraph->GetTSPTotalCost() << endl;
		cout << "  Mean cost: " << myGraph->GetTSPTotalCost()/myGraph->GetNumNodes() << endl;
		fileNames.pop_back();
	}
}

void P3App::release (void)
{
	delete myGraph;
}
